package ru.it.xml;

import java.io.File;
import java.io.IOException;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;

/**
 *
 * @author Dmitry
 */
public class SAXXPathParser {
    public org.w3c.dom.Element parse(Map<String, SAXQuery> queries, File file)
        throws SAXException, ParserConfigurationException, IOException {

        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
        SaxHandler handler = new SaxHandler();
        handler.queries = queries;
        parser.parse(file, handler);
        org.w3c.dom.Element ret = handler.rootnode;
        handler.close();

        return ret;
    }
}
